package com.thirdgroup.dao.impl;

import com.thirdgroup.dao.BillingOrderDao;
import com.thirdgroup.dao.base.BaseDAO;
import com.thirdgroup.pojo.entity.OrderInfo;

import java.util.List;

public class BillingOrderDaoImpl extends BaseDAO<OrderInfo> implements BillingOrderDao {
    @Override
    public List<OrderInfo> selectBycustomerID(String customerID) {
        String sql="select *\n" +
                "from order_info\n" +
                "where customerID=?";
        Object[] params={customerID};
        return findAll(sql,params);
    }

    @Override
    public Double SumBycustomerID(String customerID) {
        String sql="select sum(packageCost)\n" +
                "from order_info\n" +
                "where customerID=?";
        Object[] params={customerID};
        return (Double) super.getValue(sql,params);
    }

    @Override
    public Double Sum() {
        String sql="select sum(packageCost) from order_info";
        return (Double) super.getValue(sql,null);
    }
}
